<div class="container-fluid">

                <!-- Page Heading -->
                <div class="row">
                    <div class="col-lg-12">
		
                       <ol class="breadcrumb" style="margin-top:8px;position:relative;">
                            <li>
                                <i class="fa fa-cube"></i>  菜单管理
                            </li>
                            <li class="active">材料管理
                            </li>
                            <li class="active">编辑材料
                            </li>
                            <div style="position:absolute;right:2%;top:23%;cursor:pointer;">
                			<i class="fa fa-arrow-circle-left fa-lg"   onclick="window.location.href='/ingredient'"></i>
                		</div>                               
                        </ol>
                    </div>
                </div>
                <form method="post" action="/updateingredient">
                
                <div class="row">
					<div class="panel-body">
                            <div class="row">
                                <div class="col-lg-12">
                                    <form role="form">
                                    	  <label>材料类型</label>
                                    	    <div class="form-group input-group">
								            <select class="form-control" name="ingredientType" id="ingredientType">
		
								            </select>
								            <span class="input-group-btn">
								            	<button class="btn btn-default" type="button" onclick=" delIType()" id="delbtn"><i class="fa fa-minus-circle" style="cursor:pointer;"></i> </button>
								            	<button class="btn btn-default" type="button" onclick="addIType()"><i class="fa fa-plus-circle"></i></button>
								            </span>
								          </div>
                                        <div class="form-group">
                                            <label>材料名称</label>
                                            <input class="form-control" name="ingredientname" value="<%=ingredient.name %>">
                                        </div>
                    
                                         <input type="hidden" name="id" value="<%=ingredient.id %>">
                                              <div align="right">
                                        	<button type="submit" class="btn btn-default">保存</button>
                                        	</div>
                                    </form>
                                </div>

                            </div>
                            <!-- /.row (nested) -->
                        </div>
                </div>
                </form>
            </div>
            <script>
     
            	
            		 function delIType(){
            	 		if(confirm("确认删除该条记录?")){
            	 			  var id=$("#ingredientType").val();
            				 $.get("/ingredient/delitype",{id:id},function(data){
            		 	getITypeList();
            			 });
						}

            	}
            
            	function addIType(){
            		 var name=prompt("请输入新增的材料类型名称"); 
            	if(name!==null){
            		 $.post("/ingredient/additype",{itypename:name},function(data){
            		 	getITypeList();
            		 });
            		 }
            	}
            	
            	function getITypeList(){
            			$("#ingredientType").dsel("/ingredient/itypelist","<%=ingredient.type._id%>","暂无材料类型",false,function(len){
						if(len>0){
	            			$("#delbtn").removeAttr("disabled");  
	            		}else{
	            			$("#delbtn").attr("disabled","disabled");
	            		}
						});
            	}
            	
            	 getITypeList();
            </script>
